package com.peng.servlet;

import com.peng.dao.impl.regionDaoImpl;
import com.peng.dao.impl.userDaoImpl;
import com.peng.dao.regionDao;
import com.peng.dao.userDao;
import com.peng.entity.region;
import com.peng.entity.user;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by 欧阳欣鹏 on 2018/8/14.
 */
public class FindbyIdUserServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int id=Integer.parseInt(request.getParameter("id"));
        String x=request.getParameter("id");
        userDao u=new userDaoImpl();
        regionDao rdao=new regionDaoImpl();
        user us=u.findbyUid(id);

        int pro=us.getUprovince();
        region a= rdao.findregioname(pro);
        String namepro=a.getAreaName();
        us.setUprovinces(namepro);

        int city=us.getUcity();
        region b= rdao.findregioname(city);
        String namecity=b.getAreaName();
        us.setUcitys(namecity);

        int area=us.getUcounty();
        region c=rdao.findregioname(area);
        String namearea=c.getAreaName();
        us.setUcountys(namearea);

        request.setAttribute("us",us);
       request.getRequestDispatcher("admin-edit.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
    }
}
